// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

// ElementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'v-charts/lib/style.css'

// api
import api from './fetch/api'

// config
import * as constant from './config/constant'

// Utils
import * as BastUtils from './utils/BastUtils'

// v-charts
import VCharts from 'v-charts'

// Vue-Quill-Editor
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

//  缓存
import db from './fetch/db';

Vue.use(VCharts)
Vue.use(ElementUI)

// 富文本工具参数
let toolbarOptions = {
  placeholder: '请输入编辑内容',
  theme: 'snow',
  modules: {
    toolbar: [
      ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
      ['blockquote', 'code-block'],

      [{'header': 1}, {'header': 2}],               // custom button values
      [{'list': 'ordered'}, {'list': 'bullet'}],
      [{'script': 'sub'}, {'script': 'super'}],      // superscript/subscript
      [{'indent': '-1'}, {'indent': '+1'}],          // outdent/indent
      [{'direction': 'rtl'}],                         // text direction

      [{'size': ['small', false, 'large', 'huge']}],  // custom dropdown
      [{'header': [1, 2, 3, 4, 5, 6, false]}],

      [{'color': []}, {'background': []}],          // dropdown with defaults from theme
      [{'font': []}],
      [{'align': []}],

      ['clean'],                                         // remove formatting button
      ['link', 'image', 'video']
    ]
  }
};

Vue.use(VueQuillEditor, toolbarOptions);

Vue.config.productionTip = false;
Vue.prototype.api = api;
Vue.prototype.constant = constant;
Vue.prototype.BaseUtils = BastUtils;
Vue.prototype.db = db;

/* eslint-disable no-new */
export default new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
})

// 路由拦截
router.beforeEach((to, from, next) => {
  // if(!localStorage.getItem(constant.LOGIN_STATUS)){
  //   if(to.name == 'Login'){
  //     next();
  //   }else{
  //     next(false);
  //   }
  //   return false;
  // }
  next();
})
